package com.qf.service.impl;

import com.qf.commns.RespData;
import com.qf.mapper.UserMapper;
import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public RespData login(String userName, String password) {
        User user = userMapper.findUserByName(userName);
        if(user!=null)
        {
            if (DigestUtils.md5DigestAsHex(password.getBytes()).equals(user.getUserPwd())) {
                return RespData.okData("登录成功",user);
            }else {
                return RespData.errorData("密码错误");
            }

        }
        return RespData.errorData("用户不存在");

    }
}
